import { post, get } from '@/utils/ajax'
import defaultSettings from '@/settings'
import { AxiosPromise } from 'axios'
import { MenuQuery, MenuVO, MenuForm } from './types'

// 获取路由
export const getRouters = () => {
  return post(defaultSettings.isCould === true ? '/auth-service/getRouters' : '/getRouters', {}, {noLoading: true})
}
/**
 * 获取路由列表
 */
export function listRoutes() {
  return get('/api/v1/menus/routes')
}

/**
 * 获取菜单树形列表
 *
 * @param queryParams
 */
export function listMenus(queryParams: MenuQuery): AxiosPromise<MenuVO[]> {
  return get('/api/v1/menus', queryParams)
}

/**
 * 获取菜单下拉树形列表
 */
// export function listMenuOptions(): AxiosPromise<OptionType[]> {
//   return get('/api/v1/menus/options')
// }

/**
 * 获取菜单表单数据
 *
 * @param id
 */
export function getMenuForm(id: number): AxiosPromise<MenuForm> {
  return get('/api/v1/menus/' + id + '/form')
}

/**
 * 添加菜单
 *
 * @param data
 */
export function addMenu(data: MenuForm) {
  return post('/api/v1/menus', data)
}

/**
 * 修改菜单
 *
 * @param id
 * @param data
 */
export function updateMenu(id: string, data: MenuForm) {
  // return request({
  //   url: '/api/v1/menus/' + id,
  //   method: 'put',
  //   data: data
  // });
}

/**
 * 删除菜单
 *
 * @param id 菜单ID
 */
export function deleteMenu(id: number) {
  // return request({
  //   url: '/api/v1/menus/' + id,
  //   method: 'delete'
  // });
}
